/**
 * Created by Administrator on 2017/9/11.
 */
let msg = require('../util/msg.js');
let chip = require('./chip.js');
let slotMachine = require('./slotMachine.js');

module.exports = action;

function action(obj, cid) {
    if (!obj.userId) {
        msg.send(cid, obj.uuid, 'error', {'api': obj.action, 'code': 10018});
        return false;
    }
    let data = obj.data;
    switch (obj.action) {
        case 'activityChipTrade':
            chip.trade(obj.userId, cid, obj.uuid, data);
            break;
        //case 'activityChipBuy':
        //    chip.buy(obj.userId, cid, obj.uuid, data);
        //    break;
        //case 'activityChipSell':
        //    chip.sell(obj.userId, cid, obj.uuid, data);
        //    break;
        case 'activitySlotMachineJoin':
            slotMachine.join(obj.userId, cid, obj.uuid, data);
            break;
        case 'activitySlotMachinePlay':
            slotMachine.play(obj.userId, cid, obj.uuid, data);
            break;
        case 'activitySlotMachineDouble':
            slotMachine.double(obj.userId, cid, obj.uuid, data);
            break;
        case 'activitySlotMachineDice':
            slotMachine.dice(obj.userId, cid, obj.uuid, data);
            break;
        case 'activitySlotMachineReturn':
            slotMachine.return(obj.userId, cid, obj.uuid, data);
            break;
        case 'activitySlotMachineExit':
            slotMachine.exit(obj.userId, cid, obj.uuid, data);
            break;
    }
}